import os
from datetime import timedelta

class Config:
    """基本配置"""
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard-to-guess-string'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY') or 'jwt-secret-key'
    JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=24)
    JWT_HEADER_NAME = "Auuua"
    JWT_HEADER_TYPE = ""  # 移除 'Bearer ' 前缀
    
    @staticmethod
    def init_app(app):
        pass

class DevelopmentConfig(Config):
    """开发环境配置"""
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \
        'mysql+pymysql://pickupchina:picSdrkKJH#8upchina@rm-bp1o13b8ww7xy8o93co.mysql.rds.aliyuncs.com/hairshop_dev'

class TestingConfig(Config):
    """测试环境配置"""
    TESTING = True
    SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \
        'mysql+pymysql://pickupchina:picSdrkKJH#8upchina@rm-bp1o13b8ww7xy8o93co.mysql.rds.aliyuncs.com/hairshop_dev'

class ProductionConfig(Config):
    """生产环境配置"""
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
        'mysql+pymysql://pickupchina:picSdrkKJH#8upchina@rm-bp1o13b8ww7xy8o93co.mysql.rds.aliyuncs.com/hairshop'

config = {
    'development': DevelopmentConfig,
    'testing': TestingConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
}